<?php
if (!defined('IN_SITE'))
{
    die('Hacking attempt');
}
if (__FILE__ == '')
{
    die('Fatal error code: 0');
}
$action=strtolower(trim($_REQUEST['act']));
$action=empty($action)?"default":trim($action);
define('ROOT_PATH', str_replace('include/init.php', '', str_replace('\\', '/', __FILE__)));
include_once(ROOT_PATH.'config.inc.php');
$_CFG=array(
'db_host'=>$db_host,
'db_user'=>$db_user,
'db_pwd'=>$db_pwd,
'db_database'=>$db_database,
'db_prefix'=>$db_prefix,
'db_update'=>$db_update,
'site_name'=>$site_name,
'site_url'=>$site_url,
'keywords'=>$keywords,
'description'=>$description,
'help_floder'=>$help_floder,
'smtp_mail'=>$smtp_mail,
'mail_service'=>$mail_service,
'mail_charset'=>$mail_charset,
'smtp_host'=>$mail_config['smtp_host'],
'smtp_port'=>$mail_config['smtp_port'],
'smtp_user'=>$mail_config['smtp_user'],
'smtp_pass'=>$mail_config['smtp_pass'],

);
include_once(ROOT_PATH.'include/lib_main.php');
include_once(ROOT_PATH.'include/lib_common.php');
include_once(ROOT_PATH.'include/cls_mysql.php');

/*include_once(ROOT_PATH.'include/cls_sql_executor.php');*/
$dtb=new dtb($_CFG['db_database'],$_CFG['db_prefix']);
$db = new cls_mysql($db_host, $db_user, $db_pwd, $db_database);
$db_host = $db_user = $db_pwd = $db_database = NULL;
$ip=real_ip();

//  加载Smarty 模板引擎
if(SET_Smarty){
	header("Content-Type:text/html; charset=utf-8");
    include_once ROOT_PATH.'include/SmartyTemplate/Smarty.class.php';
	$tpl = new Smarty();
    $tpl->caching = $tpl_caching;
    $tpl->cache_lifetime = 300;
    $tpl->template_dir = ROOT_PATH."template";
    $tpl->compile_dir = ROOT_PATH."Tmp/compile" ;
    $tpl->cache_dir = ROOT_PATH."Tmp/cache" ;
    $tpl->assign('TIME',date('Y-M-D H:i:s'));
    $tpl->assign('CFG',$_CFG);
    $tpl->assign('action',$action);
    
    if(!empty($_SESSION['user_id'])){
    $tpl->assign('mydetil',$dtb->mydetil($_SESSION['user_id']));
    }
}
if(NOSET_AJAX){
$checknotloginarray=array('default','login','reg','savereg','actlogin','loginout','loginout','orthers','help','index','game');
if(!in_array($action,$checknotloginarray)){
    $dtb->set_user_login();
}}else{
   header("Content-Type:text/javascript; charset=utf-8"); 
}
?>